<template>
  <div class="register-area" data-info="自动结算">
    <el-button class="next" @click="handleNext" type="primary">
      下一步{{ steps }}
    </el-button>

    <div class="step-comps-area" data-info="具体的业务">
      <component :is="curCompName" @handleSure="handleSure" />
    </div>
    <!--底部操作-->
    <PatientNumberOperate @handleBack="handlePre" :time="120000"/>
  </div>
</template>

<script>
import CardType from "@sc/DRCbiz/comps/cardType/index.vue";
import MedInsCode from "@sc/DRCbiz/comps/medInsCode/index.vue";
import PatientInfo from "@sc/DRCbiz/comps/patientInfo/index.vue";
import AutoStlmtResult from "@sc/DRCbiz/comps/autoStlmtResult/index.vue";
import PatientNumberOperate from "@sc/DRCbiz/comps/patientNumberOperate/index.vue";
import PaymentAndSettlement from "@sc/DRCbiz/comps/Payment-and-settlement/index.vue";
import SelectPaymentMethod from "@sc/DRCbiz/comps/Select-payment-method/index.vue";
import PaymentReminder from "@sc/DRCbiz/comps/Payment-reminder/index.vue";
import PaymentSuccess from "@sc/DRCbiz/comps/Payment-success/index.vue";

import { AndroidToWeb, buildParentApi } from "@/utils/designer/util";
let buildParent = buildParentApi();
export default {
  name: "autoStlmt",

  componentName: "autoStlmt",

  components: {
    CardType,
    MedInsCode,
    PatientInfo,
    AutoStlmtResult,
    PatientNumberOperate,
    PaymentAndSettlement,
    SelectPaymentMethod,
    PaymentReminder,
    PaymentSuccess
  },

  data() {
    return {
      steps: 1,
      curCompName: "CardType",
      compsOptions: {
        1: "CardType",
        2: "MedInsCode",
        3: "PatientInfo",
        4: "AutoStlmtResult",
        5: "PaymentAndSettlement",
        6: "SelectPaymentMethod",
        7: "PaymentReminder",
        8: "PaymentSuccess"
      },
    };
  },

  computed: {
    shownOperate() {
      return this.steps !== 1;
    },
    patientInfo() {
      return this.$store.getters["DRCbiz/getPatientInfo"];
    },
  },

  mounted() {
    this.$store.dispatch("DRCbiz/setCTDTimeInfo", 1200000);
  },

  methods: {
    handleSure(useMsg) {
      console.log("sure1", useMsg, this.patientInfo);
      // 明细
//        <Request>
//   <deviceIp>172.17.43.202</deviceIp>
//   <flowId>JWS30320250206081221928</flowId>
//   <timestamp>20250206081221928</timestamp>
//   <terminalNo>JWS303</terminalNo>
//   <method>QueryCostDetail</method>
//   <patientId>4026835</patientId>
//   <billNo>032920066,032920067,032920068,032920069,032920070,032920071</billNo>
// </Request>
      // 概要
      // <Request>
      //   <deviceIp>172.17.43.202</deviceIp>
      //   <flowId>JWS30320250206081219385</flowId>
      //   <timestamp>20250206081219385</timestamp>
      //   <terminalNo>JWS303</terminalNo>
      //   <method>QueryCostSummary</method>
      //   <patientId>4026835</patientId>
      // </Request>
      const { patientId } = this.patientInfo
      let params = {
        Request: {
          deviceIp: "",
          flowId: "",
          timestamp: "",
          terminalNo: "",
          method: "QueryCostDetail",
          patientId, // 医院病人id	C	不可空	根据医院要求确定是否可空
        },
      };
      let paramsInfo = this.$x2js.js2xml(params);
      buildParent.executeParentMethod(
        "axiosRep",
        paramsInfo,
        "QueryCostDetail"
      );
      // 出参
        // "RecordInfo": [
        //   {
        //     "billNo": "18059239",
        //     "billDate": "2025/2/6 16:37:00",
        //     "billType": "西药",
        //     "deptCode": "261",
        //     "deptName": "妇科综合门诊",
        //     "doctCode": "8628",
        //     "doctName": "於莉英",
        //     "productCode": "512947",
        //     "itemName": "D葡萄糖注射液",
        //     "itemSpecs": "20ml:10g(50%)",
        //     "itemLiquid": "注射液",
        //     "itemUnits": "瓶",
        //     "itemQty": "8",
        //     "itemPrice": "113",
        //     "billFee": "904",
        //     "itemNo": "7101464",
        //     "hosFeeNo": "512947",
        //     "diseasetype": "0"
        //   },
        //   {
        //     "billNo": "032931685",
        //     "billDate": "2025/2/6 16:36:54",
        //     "billType": "检查",
        //     "deptCode": "261",
        //     "deptName": "妇科综合门诊",
        //     "doctCode": "8628",
        //     "doctName": "於莉英",
        //     "productCode": "87",
        //     "itemName": "静脉采血",
        //     "itemUnits": "次",
        //     "itemQty": "1",
        //     "itemPrice": "580",
        //     "billFee": "580",
        //     "itemNo": "42430725",
        //     "hosFeeNo": "87",
        //     "diseasetype": "0"
        //   },
        // ]
    },
    handleNext() {
      if (this.steps === 8) {
        this.steps = 1;
      } else {
        this.steps = ++this.steps;
      }
    },

    // 返回上一层&首页
    handlePre() {
      clearInterval(this.timer);
      if (this.steps === 1) {
        this.$router.push({
          path: `/DRCbizList`,
        });
      } else {
        this.steps = --this.steps;
      }
    },
  },

  watch: {
    // 步距
    steps: {
      handler: function (val) {
        const self = this;
        self.curCompName = Reflect.get(self.compsOptions, val);
      },
      deep: true,
      immediate: true,
    },
  },
};
</script>

<style scoped lang="scss">
@import "./assets/style";
</style>